package club.pchome.controller;

import club.pchome.common.util.PageUtil;
import club.pchome.dto.Result;
import club.pchome.model.TFeedback;
import club.pchome.model.TOrder;
import club.pchome.service.TFeedBackService;
import club.pchome.service.TOrderService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Watler
 */
@RestController
public class TFeedBackController extends BaseController {


    @Autowired
    TFeedBackService tFeedBackService;

    @ApiOperation(value = "意见反馈列表")
    @ApiImplicitParams({ @ApiImplicitParam(name = "currPage", value = "当前页"), @ApiImplicitParam(name = "pageSize", value = "每页条数,0为全部")})
    @PostMapping("/feedBackList")
    public PageUtil<TFeedback> userList(HttpServletRequest request, TFeedback tFeedback, String page, String limit){
        Map<String, Object> map = new HashMap<String, Object>();

        map.put("TFeedback", tFeedback);

        PageUtil<TFeedback> pu = new PageUtil<TFeedback>(page, limit);
        return tFeedBackService.feedBackList(pu , map);
    }


    @PostMapping(value = "/updateTFeedbackIndex")
    public Result<String> updateTFeedbackIndex(TFeedback tFeedback) {

        long result = tFeedBackService.updateTFeedbackIndex(tFeedback);

        if (result <= 0) {
            return Result.initFailureResult(20001 , "回复失败");
        } else {
            return Result.initSuccessResult("操作成功");
        }
    }
}
